<?php
	require_once($_SERVER["DOCUMENT_ROOT"]."/global.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/modules/security_mod.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/alerter/modules/account_mod.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/alerter/modules/alert_mod.php");

	SecurityMod::login();

	$level = $_SESSION["account"]->getLevel();
	if ($level != "Admin" && $_SESSION["account"]->getAdvanced() == 0 && $_SESSION["account"]->getSecret() == 0)
		SecurityMod::logout();

	$alertAccount = AlertAccountMod::getAccount($_SESSION["account"]->getName());
	$alertTypes = AlertMod::getManualAlertTypes();
	$sectors = AlertMod::getSectors();
	

?>
<html>
<head>
<title><?php echo(SettingsMod::PAGE_TITLE." :: Manual Alert"); ?></title>
<link rel="stylesheet" href="main.css">
</head>
<body>
	<h2 align="center">Create Manual Alert</h2>
	<form method="post" action="manual_alert_add.php">
	<input type="hidden" name="alerter" value="<?php echo($alertAccount->getID()); ?>" />
	<table width="500px" background="<?php echo(SettingsMod::STATIC_IMAGES)?>/bgd.gif" class="messagestyle" align="center">
	<tr>
		<th>Alert type:</th>
		<td>
		<select name="alertType" style="width: 100%">
		<?php foreach($alertTypes as $alertType): ?>
			<option value="<?php echo($alertType->getId()) ?>"><?php echo($alertType->getType()); ?></option>
		<?php endforeach; ?>
		</select>
		</td>
	</tr>
	<tr>
		<th>Sector:</th>
		<td>
		<select name="sector" style="width: 100%">
		<?php foreach($sectors as $sector): ?>
			<option value="<?php echo($sector) ?>"><?php echo($sector); ?></option>
		<?php endforeach; ?>
		</select>
		</td>
	</tr>
	<tr>
		<th>Coords, w/o brackets:</th>
		<td><input type="text" name="coords" style="width: 100%" value="" /></td>
	</tr>
	<tr>
		<th>Header:</th>
		<td><input type="text" name="header" style="width: 100%" value="" /></td>
	</tr>
	<tr>
		<th>Details:</th>
		<td><textarea name="details" style="width: 100%" rows="5" /></textarea></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="Save alert" /></td>
	</tr>
	</table>
	</form>
</body>
</html>